#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define eb emplace_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;
using ll = long long;
using db = double;
using tl = tuple < int, int, int >;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e5 + 10;

int n, L, R, siz[N], son[N], RT;
bool tvis[N];
ll ans;
veg G[N];
veg pot;

struct Tr {
	int tr[N];
	void add(int x, int v) { x++; for(; x <= n + 1; x += x & -x) tr[x] += v; }
	int query(int x) { int res = 0; x++; for(; x; x -= x & -x) res += tr[x]; return res; }
	int query(int l, int r) { return l > r ? 0 : (r < 0 ? 0 : query(r)) - (l - 1 < 0 ? 0 : query(l - 1)); }
} T;

void getsz(int x, int p) {
	siz[x] = 1; for(auto v : G[x]) if(v.fi ^ p && !tvis[v.fi]) getsz(v.fi, x), siz[x] += siz[v.fi];
}

void getrt(int x, int p, int tsiz) {
	son[x] = 0; for(auto v : G[x]) if(v.fi ^ p && !tvis[v.fi]) son[x] = max(son[x], siz[v.fi]), getrt(v.fi, x, tsiz);
	son[x] = max(son[x], tsiz - siz[x]); if(!RT || son[x] < son[RT]) RT = x;
}

void tdfs(int x, int p, int cnt, int mx) {
	pot.eb(mx, cnt);
	for(auto v : G[x]) if(v.fi ^ p && !tvis[v.fi]) tdfs(v.fi, x, cnt + 1, max(mx, v.se));
}

ll calc(int x, int cnt, int mx) {
	pot.clear(); tdfs(x, 0, cnt, mx);
	ll res = 0; sort(pot.begin(), pot.end());
	for(auto v : pot) {
		int mx, cnt; tie(mx, cnt) = v;
		res += 1ll * T.query(L - cnt, R - cnt) * mx;
		T.add(cnt, 1);
	}
	for(auto v : pot) T.add(v.se, -1); return res;
}

void divide(int x) {
	getsz(x, 0); RT = 0; getrt(x, 0, siz[x]); x = RT; tvis[x] = true; ans += calc(x, 0, 0);
	for(auto v : G[x]) if(!tvis[v.fi]) ans -= calc(v.fi, 1, v.se);
	for(auto v : G[x]) if(!tvis[v.fi]) divide(v.fi);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
	n = in, L = in, R = in;
	rep(i, 2, n) {
		int u = in, v = in, w = in;
		G[u].eb(v, w); G[v].eb(u, w);
	}
	divide(1);
	printf("%lld\n", ans * 2); return 0;
}
